import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;

/**
 * Write a description of class Lives here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Lives extends Actor
{
    public Lives()
    {
        setImage("hat.png");
        updateImage(5);
    }
    
    public void act() 
    {
        setLocation(getImage().getWidth()/2+20,getY());
    }    
    
    public void updateImage(int lives)
    {
        if(lives<=0)
        {
            GreenfootImage image=new GreenfootImage(40,30);
            image.setColor(new Color(0,0,0,0));
            image.fill();
            setImage(image);
            return;
        }
        
        GreenfootImage image=new GreenfootImage(40*lives,30);

        GreenfootImage hat=new GreenfootImage("hat.png");
        
        for(int i=0;i<lives;i++)
        image.drawImage(hat,40*i,0);
        
        setImage(image);
    }
        
}
